package com.anyonavinfo.cpaddemo.data.radioinfo.source.local;

import android.content.Context;
import android.content.SharedPreferences;

import com.anyonavinfo.cpaddemo.Application;

/**
 * Created by ZuiC on 2017/2/8.
 */

public class RadioInfoLocalDataSourceHelper {

    private Context mContext;

    public RadioInfoLocalDataSourceHelper() {
        mContext = Application.getContextObject();
    }

    public void saveRadioStation(int position, int frq) {
        SharedPreferences radioStation = mContext.getSharedPreferences(
                "RadioStation", 0);
        SharedPreferences.Editor editor = radioStation.edit();
        editor.putInt("frq", frq);
        editor.putInt("position", position);
        editor.commit();
    }

    public int[] readRadioStation() {
        SharedPreferences radioStation = mContext.getSharedPreferences(
                "RadioStation", 0);
        int stations[] = new int[6];
        for (int i = 0; i < stations.length; i++) {
            if (i < 3) {
                stations[i] = radioStation.getInt(String.valueOf(i + 1), 531);
            } else {
                stations[i] = radioStation.getInt(String.valueOf(i + 1), 875);
            }
        }
        return stations;
    }
}
